# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2024/1/5 13:27
from selenium.webdriver.common.by import By
from datetime import datetime


class ProductNetworkLocator:

    # 查询列表status数据项(//span[text()="Status"]/..//span[@role="button"])[2]
    click_status = (By.XPATH,'(//span[text()="Status"]/..//span[@role="button"])[2]')
    # network页面
    network_page = (By.XPATH, '//*[@id="root"]/section/section/main/div/main/div/div/div/div[2]/div[2]/div[1]/div[1]/div/div[4]')
    # 根据product name查询，instance id查询等
    select_term = (By.XPATH,'(//input[@id="paramType"]/..)[2]')
    # product name下拉选择
    select_list = (By.CSS_SELECTOR,'[class="antd4-select-item-option-content"]')
    # search product
    search_product = (By.XPATH,'//div[contains(@class,"tabs-tabpane-active")]//input[@id="offerId"]')
    # 判断查询条件是否可见
    visibility_of_judgment_product = (By.XPATH,'//*[@class="antd4-select-item antd4-select-item-option antd4-select-item-option-active"]/*[@class="antd4-select-item-option-content"]')
    # 接口超时提醒
    timeout_alert = (By.XPATH,'//*[@class="ant-message-custom-content ant-message-warning"]/span')
    # saerch按钮
    search = (By.XPATH,'//div[contains(@class,"tabs-tabpane-active")]//span[text()="Search"]/..')
    # 列表product列
    search_list = (By.XPATH,'(//tbody[@class="antd4-table-tbody"])[3]/tr[@class="antd4-table-row antd4-table-row-level-0"]/td[@class="antd4-table-cell"][2]/div')
    # 获取列表第一行数据
    first_id = (By.XPATH,'(//tbody[@class="antd4-table-tbody"])[2]/tr[2]/td/div/a')
    # organization
    search_org = (By.XPATH,'(//span[@class="antd4-select-selection-item"])[6]')
    # organization list
    search_org_list = (By.XPATH,'(//tbody[@class="antd4-table-tbody"])[2]/tr[@class="antd4-table-row antd4-table-row-level-0"]/td[13]/div')
    # ...
    first_setting = (By.XPATH,'(//tbody[@class="antd4-table-tbody"])[2]/tr[2]/td[15]/div/div[3]/span')
    # create_time desc
    create_time_desc = ()
    # release
    release = (By.XPATH,'//*[text()="Release"]')
    # first status
    first_status = (By.XPATH,'//*[@role="tabpanel" and @aria-hidden="false"]//*[@class="antd4-table-tbody"]/tr[2]//div[@class="antd4-space-item"][2]')
    # first renew
    first_renew = (By.XPATH,'//*[@role="tabpanel" and @aria-hidden="false"]//*[@class="antd4-table-tbody"]/tr[2]//span[text()="Renew"]/..')
    # first_expired_time
    first_expired_time = (By.XPATH,'//*[@role="tabpanel" and @aria-hidden="false"]//*[@class="antd4-table-tbody"]/tr[2]/td[7]/div/span/span[1]')





    # NAT Gateways录入页面
    # name录入
    input_name = (By.XPATH,'//*[@id="creForm_name"]')
    # VPC
    vpc = (By.XPATH,'//*[@id="creForm_vpcId"]/div[1]/div/div/span[2]')
    # VPC选择
    select_vpc = (By.CSS_SELECTOR,'[class="rc-virtual-list-holder-inner"]>:nth-child(1)')
    # read_and_agree
    read_and_agree = (By.CSS_SELECTOR,'[class="antd4-checkbox"]')
    # Buy Now
    buy = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary"]')

    # 等待转菊花
    wait_for_pay = (By.CSS_SELECTOR,'[class="antd4-spin-dot antd4-spin-dot-spin"]')

    # Pay页面
    # Pay按钮
    pay = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary footerBtn___1_1RN"]')

    # Payment Successful页面
    check_order = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-default"]')


    """
    NAT Gateways 控制台页面
    """
    # ifarme
    iframe=(By.CSS_SELECTOR,'[id="hj_container"]')
    # 用于检查NAT Gateways文本
    check_nat_gateways = (By.XPATH,'//*[@id="icestarkNode"]/div/div[1]/header/section/section[1]/section[1]/div/div[1]/div')
    # 根据gateway name搜索
    search_by = (By.CSS_SELECTOR,'[placeholder="Search by NAT gateway name"]')
    # search按钮
    nat_search = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div/div[1]/button[2]')
    # ... 按钮
    setting = (By.CSS_SELECTOR,'[class="teamix-icon teamix-icon-more-line teamix-medium"]')
    # delete
    delete = (By.CSS_SELECTOR,'[class="next-menu next-ver next-overlay-inner"]>:nth-child(3)')
    # 删除之前勾选确认
    confirmed = (By.XPATH,'/html/body/div[6]/div[2]/div/div[2]/div/div/div[2]/label/span[1]')
    # 提交
    submit = (By.CSS_SELECTOR,'[class="next-btn next-medium next-btn-primary next-dialog-btn"]')
    # 查询列表total
    total = (By.CSS_SELECTOR,'[class="next-pagination-total"]')


    """
    create VPN Gateways 页面
    """
    # click organization
    organization = (By.XPATH,'//span[@class="antd4-select-selection-item"]')
    # select organization list
    organization_list = (By.CSS_SELECTOR,'[class="antd4-select-tree-title"]')
    # auto named vpn
    gateway_name = (By.XPATH,'//*[@id="creForm_gatewayName"]')
    # vpc&vswitch 1
    click_vpc_vswitch1 = (By.XPATH,'//*[@id="creForm_vpcId"]/..')
    #
    vpc_vswitch_list1 = (By.XPATH,'(//*[@id="creForm_vpcId_list"]/..//div[@class="antd4-select-item-option-content"])[1]')
    # vpc&vswitch 2
    click_vpc_vswitch2 = (By.XPATH,'//*[@id="creForm_vSwitchId"]/..')
    #
    vpc_vswitch_list2 = (By.XPATH,'(//*[@id="creForm_vSwitchId_list"]/..//div[@class="antd4-select-item-option-content"])[1]')
    # agreement
    agree = (By.CSS_SELECTOR,'[class="antd4-checkbox"]')


    """
    delete 页面
    """
    # Delete
    setting_delete = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary antd4-btn-lg releaseBtn___27j7c"]')
    # 确认删除
    yes_delete = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary"]')
    # 确认删除成功
    sure = (By.CSS_SELECTOR,'[class="resultTitle___2AfnO"]')


    """
    Renew Package
    """
    # New Expiration Date
    new_expiration_date = (By.CSS_SELECTOR,'[class="newExpirationDate___3OiQT"]')
    # Payment Successful
    pay_success = (By.CSS_SELECTOR,'[class="antd4-result-title"]')


    """
     VPC控制台
    """
    # (//div[@class="productBtn___2kdzl"])[6]
    vpc_create = (By.XPATH,'(//div[@class="productBtn___2kdzl"])[6]')
    # 用于判断是否进入vpc控制台
    check_vpc_success = (By.CSS_SELECTOR,'[class="teamix-nav-sidebar-header-name"]')
    # vpc控制台菜单
    vpc_menu = (By.XPATH,'(//span[@class="teamix-typography teamix-typography-ellipsis teamix-nav-console-sidebar-text"])[2]')
    # 创建vpc按钮
    create_vpc_button = (By.CSS_SELECTOR,'[class="next-btn next-medium next-btn-primary is-hybridcloud"]')
    # vpc name输入框
    input_vpc_name = (By.CSS_SELECTOR,'[placeholder="Search by VPC name"]')
    # vpc search
    click_vpc_search = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div/div[1]/button[2]')
    # total: Total 1
    if_total = (By.CSS_SELECTOR,'[class="next-pagination-total"]')
    # 第一条数据的management
    click_first_management = (By.XPATH,'(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[1]')
    # 查询列表第一条数据的vpc id
    find_first_vpc_id = (By.XPATH,'(//div[@class="teamix-typography"])[1]')
    # 查询列表第一条数据的vpc name
    find_first_vpc_name = (By.XPATH, '(//div[@class="as-name-editor-value"])[1]/span')
    # 查询列表第一条数据的vpc_ip
    find_first_vpc_ip = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[5]/div/div/div/a')
    # 查询列表第一条数据的org
    find_first_org = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[8]/div/div[1]')
    # 查询列表第一条数据的Resource Set
    find_first_resource_set = (By.XPATH,'//*[@id="icestarkNode"]/div/div[2]/div/div[2]/div[2]/div[2]/div[2]/table/tbody/tr/td[8]/div/div[2]')
    # delete第一条数据
    click_first_delete = (By.XPATH,'(//button[@class="next-btn next-medium next-btn-primary next-btn-text is-hybridcloud"])[2]')
    # 删除时确认ok
    click_delete_ok = (By.CSS_SELECTOR,'[class="next-btn next-medium next-btn-primary next-dialog-btn"]')






    """
     VPC创建页面
    """
    # 判断页面进入成功：Create VPC
    check_vpc_page_success = (By.CSS_SELECTOR,'[class="product-name"]')
    # 点击org
    click_org = (By.XPATH,'(//span[@class="next-select-values next-input-text-field"])[1]')
    # org下拉列表选择
    search_vpc_org_list = (By.CSS_SELECTOR,'[class="next-tree-node-label next-tree-node-label-selectable"]')
    # 输入vpc名称
    input_vpc_name = (By.CSS_SELECTOR,'[id="VpcName"]')
    # 提交后ok按钮
    click_ok = (By.XPATH,'(//button[@class="next-btn next-medium next-btn-primary is-hybridcloud"])[2]')


    """
        VPC详细页面
    """
    # vpc_id
    vpc_detail_vpc_id = (By.XPATH,'(//div[@class="as-info-item-content-cell"])[1]')
    # vpc_name
    vpc_detail_vpc_name = (By.XPATH, '(//div[@class="as-info-item-content-cell"])[2]')
    # vpc_ip
    vpc_detail_vpc_ip = (By.XPATH, '(//div[@class="as-info-item-content-cell"])[4]')
    # vpc_org
    vpc_detail_vpc_org = (By.XPATH, '(//div[@class="as-info-item-content-cell"])[10]')
    # vpc_resource_set
    vpc_detail_vpc_resource_set = (By.XPATH, '(//div[@class="as-info-item-content-cell"])[11]')


    """
       补充my resource用例
    """
    # 产品列表
    product_list = (By.CSS_SELECTOR,'[class="productBtn___2kdzl"]')
    # create_new按钮
    move_create_new = (By.XPATH,'//span[text()="Create New "]')
    # 产品查询输入框
    input_product = (By.XPATH,'//span[@class="antd4-input-affix-wrapper search-input___tn96f"]/input')

    """
      admin 页面
    """
    #  //div[text()='Product Management']
    product_management = (By.XPATH,'//div[text()="Product Management"]/..')
    # Product Management 的父亲节点
    product_management_parent_node = (By.XPATH,'//div[text()="Product Management"]/../../..')
    #  (//div[text()='Product Category'])[1]
    product_category = (By.XPATH,'(//div[text()="Product Category"])[1]')
    # Category List
    category_list = (By.XPATH,'//div[@class="list-wrapper___3xRO8"]/div/div/div//span')









